<template>
    <div class="loader" v-if="watchShow">
        <div id="ld2">
            <div>
            </div>
            <div>
            </div>
            <div>
            </div>
            <div>
            </div>
            <div>
            </div>
            <div>
            </div>
            <div>
            </div>
        </div>
    </div>
</template>

<script setup lang="ts">
import { useLoader } from "../../stores/loader";
import { toRefs, watchEffect, ref } from "vue";
const { flag } = toRefs(useLoader())
const watchShow = ref(false)
watchEffect(() => {
    watchShow.value = flag.value
    console.log(watchShow.value);
})

</script>

<style lang="scss" scoped>
.loader {
    position: absolute; 
    top: 0;
    left: 0;
    z-index: 99;
    width: 100vw;
    height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background-color: rgba(0, 0, 0, .8);
}

#ld2 {
    display: flex;
    flex-direction: row;
}

#ld2 div {
    height: 20px;
    width: 5px;
    background: #FE4A49;
    margin: 3px;
    border-radius: 25px;
}

#ld2 div:nth-child(1) {
    animation: ld2 1s ease-in-out infinite 0s;
}

#ld2 div:nth-child(2) {
    animation: ld2 1s ease-in-out infinite 0.1s;
}

#ld2 div:nth-child(3) {
    animation: ld2 1s ease-in-out infinite 0.2s;
}

#ld2 div:nth-child(4) {
    animation: ld2 1s ease-in-out infinite 0.3s;
}

#ld2 div:nth-child(5) {
    animation: ld2 1s ease-in-out infinite 0.4s;
}

#ld2 div:nth-child(6) {
    animation: ld2 1s ease-in-out infinite 0.5s;
}

#ld2 div:nth-child(7) {
    animation: ld2 1s ease-in-out infinite 0.6s;
}

@keyframes ld2 {
    0% {
        transform: scaleY(1);
        background: #FED766;
    }

    25% {
        background: #009FB7;
    }

    50% {
        transform: scaleY(2);
        background: #59CD90;
    }

    75% {
        background: #FE4A49;
    }

    100% {
        transform: scaleY(1);
        background: #D91E36;
    }
}
</style>